package com.itdct.mto.core.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Zhouwx
 * @date 2025/7/1 15:15:55
 * @version 1.0
 * @description
 */
@Configuration
public class ThreadPoolConfig {
    @Autowired
    private MtoConfig mtoConfig;

    @Bean("threadPoolExecutor")
    public ThreadPoolExecutor threadPoolExecutor() {
        int threadCount = mtoConfig.getThreadCount();
        return new ThreadPoolExecutor(threadCount, threadCount, 120, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
    }

    @Bean("dataTransferExecutor")
    public ThreadPoolExecutor dataTransferExecutor() {
        int threadCount = mtoConfig.getThreadCount();
        return new ThreadPoolExecutor(threadCount, threadCount, 120, TimeUnit.MINUTES, new LinkedBlockingQueue<>());
    }

}
